package com.wontube.core.pub;

import java.io.Serializable;

import javax.servlet.http.HttpServletRequest;

import com.wontube.client.modle.vo.ClientSession;
import com.wontube.core.pub.servlet.PostProcessor;
import com.wontube.core.pub.servlet.handlers.MethodWrapper;

/**
 * @author yuechao
 * 
 */
public final class ServerContext implements Serializable {
	private static final long serialVersionUID = 1L;
	
	/**
	 * session
	 */
	private ClientSession session;
	
	/**
	 * 请求
	 */
	private HttpServletRequest request;

	/**
	 * 响应
	 */
	private PostProcessor processor;
	
	/**
	 * 服务器错误信息
	 * 
	 */
	private String error;

	/**
	 * 当前请求的方法
	 * 
	 */
	private MethodWrapper methodWrapper;

	/**
	 * 手工设置是否取消
	 * 
	 */
	private boolean isCancel = false;
	
	/**
	 * 服务器响应
	 * 
	 */
	private Object response;
	
	/**
	 * @return the request
	 */
	public HttpServletRequest getRequest() {
		return request;
	}

	/**
	 * @param request the request to set
	 */
	public void setRequest(HttpServletRequest request) {
		this.request = request;
	}

	/**
	 * @return the processor
	 */
	public PostProcessor getProcessor() {
		return this.processor;
	}

	/**
	 * @param processor the processor to set
	 */
	public void setProcessor(PostProcessor processor) {
		this.processor = processor;
	}

	/**
	 * @return the error
	 */
	public String getError() {
		return this.error;
	}

	/**
	 * @return the methodWrapper
	 */
	public MethodWrapper getMethodWrapper() {
		return this.methodWrapper;
	}

	/**
	 * @param methodWrapper
	 *            the methodWrapper to set
	 */
	public void setMethodWrapper(MethodWrapper methodWrapper) {
		this.methodWrapper = methodWrapper;
	}

	/**
	 * @return the isCancel
	 */
	public boolean isCancel() {
		return this.isCancel;
	}

	public Object getResponse() {
		return this.response;
	}

	public void setResponse(Object response) {
		this.response = response;
	}

	public ClientSession getSession() {
		return this.session;
	}

	public void setSession(ClientSession session) {
		this.session = session;
	}

	public void error(String errMessage) {
		this.error = errMessage;
		this.isCancel = true;
	}
}
